//
//  ZToolsHeader.m
//  WeClubs
//
//  Created by Zed Link on 14/4/2017.
//  Copyright © 2017 Zed. All rights reserved.
//

#import "ZToolsHeader.h"
#import "UIButton+ZUtilities.h"
#import <Masonry.h>


@implementation ZToolsHeader

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self zLoadSubview];
    }
    return self;
}

- (void)zLoadSubview
{
    [self setBackgroundColor:NAVBAR_BG_COLOR];
    
    // ========== 分割线 ==========
//    UIView *separator = [[UIView alloc] init];
//    [separator setBackgroundColor:[UIColor zColorWithHex:DYNAMIC_SEPARATOR_BG_COLOR]];
//    [self addSubview:separator];
//    
//    [separator mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.height.mas_equalTo(1);
//        make.left.right.bottom.mas_equalTo(self);
//    }];
}

- (void)setDescriptionTitle:(NSString *)title
{
    NSDictionary *attributes = @{
                                 NSFontAttributeName : [UIFont systemFontOfSize:16 weight:UIFontWeightMedium],
                                 NSForegroundColorAttributeName : [UIColor zColorWithHex:0x333333],
                                 };
    NSAttributedString *attrTitle = [[NSAttributedString alloc] initWithString:title attributes:attributes];
    [self.descriptionBtn setAttributedTitle:attrTitle forState:UIControlStateNormal];
}

@synthesize descriptionBtn = _descriptionBtn;

- (UIButton *)descriptionBtn
{
    if (_descriptionBtn == nil) {
        _descriptionBtn = [UIButton zButtonWithTitle:@"" fontSize:16 textColor:FONT_MAIN_COLOR];
        [_descriptionBtn setTitleEdgeInsets:UIEdgeInsetsMake(0, 4, 0, 0)];
        [_descriptionBtn setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
        
        [self addSubview:_descriptionBtn];
        
        [_descriptionBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(12);
            make.top.mas_equalTo(16);
            make.size.mas_equalTo(CGSizeMake(128, 16));
        }];
    }
    return _descriptionBtn;
}

@end
